using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Common;

public partial class biz_changepassword : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        PageBegin();

        Response.Expires = -1;
        if (RequestBase.GetQueryString("username") != "")
        {
            txtUsername.Value = RequestBase.GetQueryString("username");
        }
        else
        {
            txtUsername.Value = this.UserName;
        }

        if (Common.RequestBase.GetFormString("__EVENTTARGET") == "save")
        {
            SaveChanges();
        }
    }
    void SaveChanges()
    {
        if (txtUsername.Value.Trim() == this.UserName || Validate("system user", 2))
        {
            string res = BLL.SystemUserBase.ChangePassword(txtUsername.Value.Trim(), txtPassword.Value.Trim());
            if (res == "succeeded")
            {
                JScript.AlertAndReturnValueToParent("Save succeeded!", "window.opener=null;window.close();");
            }
            else
            {
                JScript.Alert(res);
            }
        }
        else
        {
            JScript.Alert("Current user does not modify the permissions!");
        }
    }
}
